package com.ss.android.article.base.feature.detail.presenter;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bytedance.common.utility.UIUtils;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.model.VideoAlbumInfo;
import com.ss.android.article.base.ui.at;
import com.ss.android.article.browser.R;
import com.ss.android.article.common.NightModeAsyncImageView;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.common.dialog.WindowBuilder;
import com.ss.android.common.util.NetworkStatusMonitor;
import com.ss.android.image.loader.ImageLoader;
import com.ss.android.image.model.ImageInfo;
import com.ss.android.j.ClickableBackgroundCompat;

import org.json.JSONObject;

public final class t {
    public View a;
    private TextView b;
    private ImageView c;
    private NightModeAsyncImageView d;
    private TextView e;
    private TextView f;
    private TextView g;
    private TextView h;
    private VideoAlbumInfo i;
    private Context j;
    private AppData k;
    private final Resources l;
    private final NetworkStatusMonitor m;
    private final int n;
    private final int o;
    private final int p;
    private final int q;
    private ImageLoader r;
    private ImageLoader s;
    private boolean t;
    private long u;
    private final View.OnClickListener v;

    public t(Context arg2, NetworkStatusMonitor arg3, ImageLoader arg4, ImageLoader arg5, int arg6, int arg7, int arg8, int arg9) {
        this.t = false;
        this.v = new u(this);
        this.j = arg2;
        this.m = arg3;
        this.k = AppData.getInstance();
        this.l = arg2.getResources();
        this.p = arg6;
        this.q = arg7;
        this.o = arg8;
        this.n = arg9;
        this.r = arg4;
        this.s = arg5;
    }

    public final void a() {
        long v6 = 0;
        int v4 = R.color.ssxinzi3;
        if(this.t != AppData.isNightMode()) {
            this.t = AppData.isNightMode();
            ClickableBackgroundCompat.setClickableBackground(this.a, this.t);
            if(v6 > v6) {
                this.b.setTextColor(this.l.getColor(com.ss.android.article.browser.R.color.c1));
            }
            else {
                this.b.setTextColor(this.l.getColor(com.ss.android.article.browser.R.color.ssxinzi2));
            }

            this.c.setImageResource(com.ss.android.article.browser.R.color.hh);
            this.f.setTextColor(this.l.getColorStateList(com.ss.android.article.browser.R.color.update_comment_more_text_selector));
            this.f.setBackgroundResource(com.ss.android.article.browser.R.drawable.related_album_lable_bg);
            this.g.setTextColor(this.l.getColorStateList(v4));
            this.h.setTextColor(this.l.getColorStateList(v4));
            this.e.setTextColor(this.l.getColorStateList(com.ss.android.article.browser.R.color.ssxinzi12));
            this.e.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.np);
        }
    }

    public final void a(View arg5) {
        this.a = arg5.findViewById(com.ss.android.article.browser.R.id.root);
        this.c = arg5.findViewById(com.ss.android.article.browser.R.id.divider);
        this.b = arg5.findViewById(com.ss.android.article.browser.R.id.title);
        this.d = arg5.findViewById(com.ss.android.article.browser.R.id.right_image);
        this.e = arg5.findViewById(com.ss.android.article.browser.R.id.a8l);
        this.g = arg5.findViewById(com.ss.android.article.browser.R.id.video_source);
        this.h = arg5.findViewById(com.ss.android.article.browser.R.id.comment_count);
        this.f = arg5.findViewById(com.ss.android.article.browser.R.id.a6i);
        NightModeAsyncImageView v0 = this.d;
        int v1 = this.p;
        int v2 = this.q;
        ViewGroup.LayoutParams v3 = ((ImageView)v0).getLayoutParams();
        if(v3 != null) {
            if(v1 > 0) {
                v3.width = v1;
            }

            if(v2 > 0) {
                v3.height = v2;
            }

            ((ImageView)v0).setLayoutParams(v3);
        }

        this.a.setOnClickListener(this.v);
    }

    public final void a(VideoAlbumInfo arg7, long arg8) {
        int v0;
        int v1 = 0;
        long v4 = 0;
        if(arg7 != null) {
            this.i = arg7;
            this.u = arg8;
            if(this.i != null) {
                this.b.setText(this.i.title);
                TextView v2 = this.b;
                Resources v3 = this.l;
                v0 = v4 > v4 ? R.color.c1 : R.color.ssxinzi2;
                v2.setTextColor(v3.getColorStateList(v0));
                v2 = this.b;
                boolean v0_1 = v4 <= v4 ? true : false;
                v2.setEnabled(v0_1);
                this.h.setText(UIUtils.a(this.i.commentCount) + this.j.getString(com.ss.android.article.browser.R.string.de));
                this.g.setText(this.i.source);
                this.e.setText(UIUtils.a(this.i.commentCount));
                this.f.setText(this.i.showTag);
            }

            ImageInfo v0_2 = this.i.middleImage;
            if(v0_2 != null) {
                android.support.design.a.setImage(this.d, v0_2);
            }

            v0 = this.k.mFontSizePref;
            if(v0 >= 0 && v0 <= 3) {
                v1 = v0;
            }

            this.b.setTextSize(((float)z.a[v1]));
            this.a();
        }
    }

    public final void b(View view) {
        JSONObject v8;
        long v2 = 0;
        if(view != null) {
            try {
                if(this.i.videoSubject <= v2) {
                    MobClickCombiner.onEvent(this.j, "video", "detail_click_album", this.i.mediaId, 0);
                }else {
                    v8 = new JSONObject();
                    v8.put("video_subject_id", this.i.videoSubject);
                    MobClickCombiner.onEvent(this.j, "video", "detail_click_album", this.i.mediaId, 0, v8);
                }
                if(this.i != null && this.i.j != null) {
                    this.i.j.a(true);
                }

                if(!(this.j instanceof com.ss.android.article.base.feature.detail2.cc)) {
                    return;
                }

                at v1 = new at((Activity) this.j, this.m, this.r, this.s, this.p, this.q, this.o, this.n, this.u, UIUtils.getScreenHeight(this.j) - ((com.ss.android.article.base.feature.detail2.cc)this.j).k() - UIUtils.getStatusBarHeight(this.j), this.i);
                v1.p.b.height = v1.l;
                ((WindowBuilder)v1).d();
            }
            catch(Throwable v0) {
                v0.printStackTrace();
            }
        }
    }
}

